class SChainsawW extends ChainsawW;

#exec OBJ LOAD FILE=SimHostOrgTex.utx

var float NextIronTime;
//var float NextReloadTime; //oh, I have plans...

replication
{
	reliable if(Role < ROLE_Authority)
		DoLunge;
}

simulated exec function ToggleIronSights()
{
	local KFPlayerReplicationInfo KFPRI;
	
	//this functionality is available to berserkers only
	KFPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
	if (KFPRI == none || KFPRI.ClientVeteranSkill != Class'SRVetBerserker')
		return;
		
	if (
		NextIronTime <= Level.TimeSeconds &&
		!FireMode[0].bIsFiring && FireMode[0].NextFireTime < Level.TimeSeconds &&
		!FireMode[1].bIsFiring && FireMode[1].NextFireTime < Level.TimeSeconds
		)
	{
		if (Instigator != none && Instigator.Physics != PHYS_Falling)
		{
			DoLunge();
			if (ROLE < ROLE_AUTHORITY) //client-side fx, essentially
				FireMode[1].ModeDoFire();
				
			NextIronTime=Level.TimeSeconds+3.0;
		}
	}
}

simulated function DoLunge()
{
	local rotator VR; //ViewRotation
	local vector DirMomentum;
	local KFPlayerReplicationInfo KFPRI;

	KFPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
	VR = Instigator.Controller.GetViewRotation();

	if(KFPRI.ClientVeteranSkillLevel==11)
	{
		DirMomentum.X= 345.0;
		DirMomentum.Y= 0.0;
		DirMomentum.Z= 295.0; //325.0; //default kfhumanpawn jump height
	}
	if(KFPRI.ClientVeteranSkillLevel>=12)
	{
		DirMomentum.X= 475.0;
		DirMomentum.Y= 0.0;
		DirMomentum.Z= 340.0; //325.0; //default kfhumanpawn jump height
	}
	VR.Pitch=0;

	FireMode[1].ModeDoFire();
		
	Instigator.AddVelocity(DirMomentum >> VR);
}

simulated event WeaponTick(float dt)
{
	local KFPlayerReplicationInfo KFPRI;
	KFPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);
	if(KFPRI.ClientVeteranSkillLevel<11 && !KFPRI.bAdmin)
	{
		Destroy();
	}
	Super.Weapontick(dt);
}

defaultproperties
{
     BloodyMaterialRef="SimHostOrgTex.Chainsaw.Chainsaw_bloody"
     SkinRefs(0)="SimHostOrgTex.Chainsaw.Chainsaw"
     FireModeClass(0)=Class'PerksSimHostOrg.SChainsawWFire'
     FireModeClass(1)=Class'PerksSimHostOrg.SChainsawWAltFire'
     Description="A deadly weapon"
     Priority=10
     PickupClass=Class'PerksSimHostOrg.SChainsawWPickup'
     AttachmentClass=Class'PerksSimHostOrg.SChainsawWAttachment'
}
